package study.ttl.service.impl;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import study.ttl.entity.Logs;
import study.ttl.mapper.LogsMapper;
import study.ttl.service.LogService;


import java.util.List;

@Service
public class LogServiceImpl implements LogService {

    @Autowired
    private LogsMapper logsMapper;



    /**
     * 添加用户
     * @param logs
     */
    @Override
    public void add(Logs logs) {
        logsMapper.insert(logs);
    }

    /**
     * 根据id删除用户
     * @param id
     */
    @Override
    public void deleteById(Integer id) {
        logsMapper.deleteById(id);
    }


    /**
     * 修改用户信息
     * @param logs
     */
    @Override
    public void update(Logs logs) {
        logsMapper.updateById(logs);
    }

    /**
     * 根据id查询用户
     * @param id
     * @return
     */
    @Override
    public Logs selectById(Integer id) {
        Logs logs = logsMapper.selectById(id);
        return logs;
    }

    /**
     * 查询所有用户
     * @return
     */
    @Override
    public List<Logs> selectAll(Logs logs) {
        List<Logs> userList = logsMapper.selectAll(logs);
        return userList;
    }

    /**
     * 分页查询用户
     * @param pageNum
     * @param pageSize
     * @param logs
     * @return
     */
    @Override
    public PageInfo<Logs> selectPage(Integer pageNum, Integer pageSize, Logs logs) {
        PageHelper.startPage(pageNum, pageSize);
        List<Logs> logsList = logsMapper.selectAll(logs);
        return PageInfo.of(logsList);
    }

    /**
     * 批量删除用户
     * @param ids
     */
    @Override
    public void deleteBatch(List<Integer> ids) {
        logsMapper.deleteBatch(ids);
    }







}
